$(document).ready(function() {
	$(".rightContent").fadeIn(500);
	
	$("#login").validate({
		focusInvalid: false,
		focusCleanup: true,
		onkeyup: false,
		onclick: false,
		rules: {
			email: {
				required: true,
				email: true,
				rangelength: [1, 100]
			},
			pass: {
				required: true,
				engAndNum: true,
				rangelength: [10, 20]
			}
		},
		messages: {
			email: {
				required: "請填寫此欄位",
				email: "格式不正確",
				rangelength: "長度必須要在1~100之間"
			},
			pass: {
				required: "請填寫此欄位",
				rangelength: "長度必須要在10~20之間"
			}
		},
		errorPlacement: function(label, element) {
			label.css("color", "red");
			label.insertBefore(element);
		},
		submitHandler: function(form) {
			var options = {
					success: function(resp) {
						if (resp == "emailOrPasswordIsWrong") {
							$("#loginProgress").css("display", "none");
							$("#loginErrorLabel").css("display", "block");
						}
						else {
							
						}
					}
			};
			
			$("#loginErrorLabel").attr("display", "none");
			$("#loginButton").attr("disabled", true);
			$("#loginProgress").css("display", "block");
			$(form).ajaxSubmit(options);
		}
	});
});